package org.ethan.lyl;

import javax.swing.*;
import javax.swing.border.LineBorder;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class StatusDailog {
    static JDialog myFrame;
    static JLabel status;
    static {
    }
    public static void init(){
        myFrame = new JDialog();
        myFrame.setUndecorated(true);//不显示窗口边框和标题
        myFrame.setSize(200, 30);
        myFrame.setLayout(null);
        myFrame.setAlwaysOnTop(true);
        final JLabel jLabel = new JLabel("X");//放在右上角做关闭按钮
        jLabel.setFont(new Font("宋体", 0, 14));
        status = new JLabel("Stand by");//放在右上角做关闭按钮
        jLabel.setFont(new Font("宋体", 0, 14));
        myFrame.getContentPane().setBackground(new Color(255, 255, 255));
        JPanel p = ((JPanel) myFrame.getContentPane());
        p.setBorder(new LineBorder(new java.awt.Color(10, 110, 10), 1, false));
        myFrame.setBounds(Toolkit.getDefaultToolkit().getScreenSize().width - 200,
                Toolkit.getDefaultToolkit().getScreenSize().height - 70, 200, 30);
        myFrame.getContentPane().add(jLabel);
        myFrame.getContentPane().add(status);
        status.setBounds(70,7,200,20);
        jLabel.setBounds(180, 7, 20, 20);
        myFrame.setVisible(true);
        myFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        jLabel.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                /*myFrame.dispose();*/
            }

            public void mouseEntered(MouseEvent e) {
                super.mouseEntered(e);
                jLabel.setForeground(Color.red);
            }

            public void mouseExited(MouseEvent e) {
                super.mouseExited(e);
                jLabel.setForeground(Color.BLACK);
            }
        });
    }
    public static void setDailog(String text) {
        status.setText(text);
    }

    public static void main(String[] args) {
       StatusDailog.init();
    }
}